package com.sky.mapper.admin;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.AutoFill;
import com.sky.enumeration.OperationType;
import com.sky.result.Result;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.reflection.wrapper.BaseWrapper;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    List<Category> getCategoryByPage(CategoryPageQueryDTO dto);

//    @AutoFill(OperationType.INSERT)
    @Insert("insert into sky_take_out.category (id,name,sort,type,status,create_time,update_time,create_user,update_user) values(null,#{name},#{sort},#{type},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    int insertCategory(Category category);

    @AutoFill(OperationType.UPDATE)
    int updateCategoryById(Category category);

    @Delete("delete from sky_take_out.category where id = #{id}")
    int deleteCategoryById(Long id);

    List<Category> getCategoryListByType(Long type);
}
